package com.yunda.AJDeviceService.service.impl;

import com.yunda.AJDeviceService.common.service.RedisService;
import com.yunda.AJDeviceService.data.dto.LDPMldpsDto;
import com.yunda.AJDeviceService.service.LDPMService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author lq
 * @className LDPMService
 * @description TODO
 * @date 2023/2/10 11:25
 */
@Slf4j
@Service
public class LDPMServiceImpl implements LDPMService {

    @Autowired
    private RedisService redisService;

    @Value("${siteServer.ip}")
    private String siteServerIp;

    @Value("${myhttp.port}")
    private String siteServerPort;

    /**
     * LDPS服务地址请求
     * 返回LDPS地址。格式ip:port
     * @return
     */
    @Override
    public String getLdpsServiceInfo(LDPMldpsDto ldpMldpsDto){

        //存储终端获取信息
        redisService.set("elaj"+ldpMldpsDto.getId(),ldpMldpsDto,3600*24*30);


        StringBuilder address = new StringBuilder();
        address.append(siteServerIp).append(":").append(siteServerPort);

        log.info("终端发起 LDPS服务地址请求="+ldpMldpsDto+" 返回LDPS地址="+address.toString());
        return address.toString();
    }
}
